# -*- coding: utf-8 -*-
"""
Module Description: 角色信息相关
Date: 2019/5/27
Author:Bai Jin Ping
"""
from collections import defaultdict

from pyshare.dal.repository_impl import RoleRepository


def batch_query_role_name(rid_list):
    """
    合并查询[单区服]多个玩家名称的操作为一次查询
    :param rid_list:
    :return {rid: nickname, ...}
    """
    rcd_list = RoleRepository.filter_by_rid_list(rid_list, 'RoleGuid', 'NickName')

    name_dict = defaultdict(str)
    for rcd in rcd_list:
        name_dict[rcd.role_guid] = rcd.nick_name
    return name_dict
